# ------------------- Local Protest in Israel ------------------- #
#   Module:           Data construction     
#   Specifically:     Packages
#   Author:           Nina
# --------------------------------------------------------------- # 

packages_load <- function(install = FALSE) {
  # Vector of required packages
  libs <- c("readxl", "tidyverse", "dplyr", 
            "tidyr", "Hmisc", "data.table", "stringr",
            "reshape2", "vtable", "expss", "labelled", "Metrics", 
            "lubridate", "anytime",  "caret", "skimr",
            "mapview",  "sf", "vegan", "texreg", "sandwich", 
            "randomForest", "zoo", "psych", "party",
            "ggplot2", "ggrepel", "raster",
            "ggspatial", "rnaturalearth", 
            "gbm", "xtable", "permimp")
  
  # Install packages
  if(install) {
    lapply(libs, install.packages)
  }
  
  # Load packages
  lapply(libs, library, character.only=T)
  
  # Clean up
  rm(libs)
}